home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / doc / xt / xt.ms < prev    next >
Text File  |  1992-03-19  |  17KB  |  498 lines

  1. .so ../tmac/tmac.scheme
  2. .RP
  3. .TL
  4. Elk/Xt Reference Manual
  5. .AU
  6. Oliver Laumann
  7. .
  8. .Ch Introduction
  9. .PP
  10. This document provides a list of the functions, special forms, and
  11. variables exported by the Elk Scheme/Xt integration.
  12. Most of the functions are directly equivalent to a function of the
  13. X toolkit C library, so that the description need not be repeated.
  14. In such cases, only the name of the corresponding Xt function is
  15. mentioned.
  16. Thus, you should have the \f2X Toolkit Intrinsics \- C Language Interface\fP
  17. manual within reach when using this reference manual.
  18. .PP
  19. The functions listed in this document are loaded when the expression
  20. .DS
  21. .ft 5
  22. (require 'xwidgets)
  23. .ft
  24. .DE
  25. .Ix xwidgets
  26. is evaluated or, when the OSF/Motif software has been installed on
  27. your system and you want to use Motif widgets from within Scheme,
  28. when
  29. .DS
  30. .ft 5
  31. (require 'motif)
  32. .ft
  33. .DE
  34. .Ix motif
  35. is evaluated in the interpreter's top level or in a Scheme program.
  36. If you only want to use the toolkit functionality (and no widgets),
  37. evaluate
  38. .DS
  39. .ft 5
  40. (require 'xt).
  41. .ft
  42. .DE
  43. .Ix xt
  44. Note that all of the above forms cause the Elk/Xlib functions to be
  45. loaded as well.
  46. .LP
  47. Individual widgets are loaded by evaluating
  48. .DS
  49. .ft 5
  50. (load-widgets . \f2widget-names\fP)
  51. .ft
  52. .DE
  53. .LP
  54. .Id load-widgets
  55. Each \f2widget-name\fP is a symbol (not quoted, since \f2load-widgets\fP
  56. is a macro).
  57. .PP
  58. The widgets are loaded from subdirectories of ``$(TOP)/lib'' (where
  59. $(TOP) is the directory where you installed the Elk software).
  60. .PP
  61. In the following, the types of arguments of the listed procedures are
  62. not specified when they are obvious from the context or from the name.
  63. For instance, an argument named \f2widget\fP is always of type \f2widget\fP,
  64. an argument named \f2context\fP is an object of type \f2context\fP
  65. (application context), etc.
  66. Arguments the names of which end in ``?'' are always of type \f2boolean\fP.
  67. .PP
  68. In the following, each description of a procedure, special form, or
  69. variable lists the kind of object in boldface.
  70. Here, \f3procedure\fP denotes either a primitive procedure or a
  71. compound procedure, \f3syntax\fP denotes a special form or a macro,
  72. and \f3variable\fP denotes a global variable that has some initial
  73. value and can be re-assigned a new value by the user (by means
  74. of \f2set!\fP or \f2fluid-let\fP).
  75. .
  76. .Ch Widget Classes
  77. .
  78. .Pr class? x
  79. Returns #t iff \f2x\fP is an object of type \f2class\fP (widget class).
  80. .
  81. .Pr find-class name-of-class
  82. Returns the widget class of the specified name (an object of
  83. type \f2class\fP).
  84. \f2name-of-class\fP is a string or a symbol.
  85. .
  86. .Pr class-resources widget-class
  87. See \f2XtGetResourceList\fP.
  88. Returns the resource list of the specified widget class.
  89. Each element of the list is a list of three symbols \-
  90. the resource name, the resource class, and the resource type.
  91. .
  92. .Pr class-constraint-resources widget-class
  93. See \f2XtGetConstraintRespourceList\fP.
  94. Returns the list of constraint resources that are defined for the
  95. specified widget class.
  96. Each element of the list is a list of three symbols \-
  97. the resource name, the resource class, and the resource type.
  98. .
  99. .Pr class-sub-resources widget-class
  100. Returns the list of sub-resources (if there are any) of the
  101. specified widget class.  See \f2class-resources\fP above.
  102. .
  103. .Pr class-exists? name-of-class
  104. Returns #t iff a widget class of the given name exists
  105. (i.\|e. has been loaded by means of \f2load-widgets\fP).
  106. \f2name-of-class\fP is a string or a symbol.
  107. .
  108. .Ch Widget Functions
  109. .
  110. .Pr widget? x
  111. Returns #t iff \f2x\fP is an object of type \f2widget\fP.
  112. .
  113. .Pr destroy-widget widget
  114. See \f2XtDestroyWidget\fP.
  115. .
  116. .Pr create-shell application-name application-class parent display . args
  117. See \f2XtAppCreateShell\fP.
  118. \f2application-name\fP and \f2application-class\fP are strings or symbols
  119. or #f (NULL is used in the latter case).
  120. \f2parent\fP is a widget.
  121. The number of \f2args\fP must be even, the 1st, 3rd, etc. argument
  122. is the name of a resource to be set (a string or a symbol), the
  123. 2nd, 4th, etc. argument is the corresponding value.
  124. .
  125. .Pr create-widget widget-class parent . args
  126. .Up
  127. .Pr create-widget widget-name widget-class parent . args
  128. See \f2XtCreateWidget\fP.
  129. \f2widget-name\fP is a string or a symbol; \f2parent\fP is a widget.
  130. If no \f2widget-name\fP is given, the name of the widget class is used.
  131. The number of \f2args\fP must be even, the 1st, 3rd, etc. argument
  132. is the name of a resource to be set (a string or a symbol), the
  133. 2nd, 4th, etc. argument is the corresponding value.
  134. .
  135. .Pr create-managed-widget . args
  136. Applies \f2create-widget\fP to the arguments and then calls \f2manage-child\fP
  137. with the newly created widget.
  138. .
  139. .Pr realize-widget widget
  140. See \f2XtRealizeWidget\fP.
  141. .
  142. .Pr unrealize-widget widget
  143. See \f2XtUnrealizeWidget\fP.
  144. .
  145. .Pr widget-realized? widget
  146. See \f2XtIsRealized\fP.
  147. .
  148. .Pr widget-display widget
  149. See \f2XtDisplay\fP.
  150. Returns an object of type \f2display\fP.
  151. .
  152. .Pr widget-parent widget
  153. See \f2XtParent\fP.
  154. .
  155. .Pr widget-name widget
  156. See \f2XtName\fP.
  157. Returns the name of a widget as a string.
  158. .
  159. .Pr widget\(mi>window widget
  160. .Up
  161. .Pr widget-window widget
  162. See \f2XtWindow\fP.
  163. Returns an object of type \f2window\fP.
  164. .
  165. .Pr widget-composite? widget
  166. See \f2XtIsComposite\fP.
  167. .
  168. .Pr manage-children . widgets
  169. See \f2XtManageChildren\fP.
  170. .
  171. .Pr manage-child widget
  172. Calls \f2manage-children\fP with the specified widget.
  173. .
  174. .Pr unmanage-children . widgets
  175. See \f2XtUnmanageChildren\fP.
  176. .
  177. .Pr unmanage-child widget
  178. Calls \f2unmanage-children\fP with the specified widget.
  179. .
  180. .Pr widget-managed? widget
  181. See \f2XtIsManaged\fP.
  182. .
  183. .Pr widget-class widget
  184. See \f2XtClass\fP.
  185. Returns an object of type \f2class\fP.
  186. .
  187. .Pr widget-superclass widget
  188. See \f2XtSuperclass\fP.
  189. Returns an object of type \f2class\fP or the symbol \f5none\fP
  190. when the widget's class does not have a super-class.
  191. .
  192. .Pr widget-subclass? widget class
  193. See \f2XtIsSubclass\fP.
  194. .
  195. .Pr set-mapped-when-managed! widget managed?
  196. See \f2XtSetMappedWhenManaged\fP.
  197. .
  198. .Pr map-widget widget
  199. See \f2XtMapWidget\fP.
  200. .
  201. .Pr unmap-widget widget
  202. See \f2XtUnmapWidget\fP.
  203. .
  204. .Pr set-values! widget . args
  205. See \f2XtSetValues\fP.
  206. The number of \f2args\fP must be even, the 1st, 3rd, etc. argument
  207. is the name of a resource to be set (a string or a symbol), the
  208. 2nd, 4th, etc. argument is the corresponding value.
  209. .
  210. .Pr get-values widget . args
  211. See \f2XtGetValues\fP.
  212. Each \f2arg\fP is the name of a resource (a string or a symbol).
  213. Returns a list of the values of the specified resources.
  214. .
  215. .Pr widget-context widget
  216. See \f2XtWidgetToApplicationContext\fP.
  217. Returns an object of type \f2context\fP.
  218. .
  219. .Pr set-sensitive! widget sensitive?
  220. See \f2XtSetSensitive\fP.
  221. .
  222. .Pr widget-sensitive? widget
  223. See \f2XtIsSensitive\fP.
  224. .
  225. .Pr window\(mi>widget window
  226. See \f2XtWindowToWidget\fP.
  227. .
  228. .Pr name\(mi>widget root-widget name
  229. See \f2XtNameToWidget\fP.
  230. \f2name\fP is a string or a symbol.
  231. .
  232. .Pr widget-translate-coordinates widget x y
  233. See \f2XtTranslateCoords\fP.
  234. Returns the root-relative x and y coordinates as a pair of integers.
  235. .
  236. .Ch Callback Functions
  237. .
  238. .Pr add-callbacks widget callback-name . callback-functions
  239. See \f2XtAddCallbacks\fP.
  240. Adds the functions to a callback list of the specified widget.
  241. \f2callback-name\fP is a string or a symbol.
  242. Each callback function will be called with at least one argument \-
  243. the widget to which the function has been attached.
  244. .
  245. .Pr add-callback widget callback-name callback-function
  246. Calls \f2add-callbacks\fP with the specified function.
  247. .
  248. .Ch Popup Shells
  249. .
  250. .Pr create-popup-shell widget-class parent-widget . args
  251. .Up
  252. .Pr create-popup-shell widget-name widget-class parent-widget . args
  253. See \f2XtCreatePopupShell\fP.
  254. \f2widget-name\fP is a string or a symbol.
  255. If no widget name is given, the name of the shell class is used.
  256. The number of \f2args\fP must be even, the 1st, 3rd, etc. argument
  257. is the name of a resource to be set (a string or a symbol), the
  258. 2nd, 4th, etc. argument is the corresponding value.
  259. .
  260. .Pr popup shell-widget grab-kind
  261. See \f2XtPopup\fP.
  262. \f2grab-kind\fP is a symbol (\f5grab-once\fP, \f5grab-nonexclusive\fP,
  263. or \f5grab-exclusive\fP).
  264. .
  265. .Pr popdown shell-widget
  266. See \f2XtPopdown\fP.
  267. .
  268. .Ch Application Contexts
  269. .
  270. .Pr context? x
  271. Returns #t iff \f2x\fP is an object of type \f2context\fP
  272. (application context).
  273. .
  274. .Pr create-context
  275. See \f2XtCreateApplicationContext\fP.
  276. .
  277. .Pr destroy-context context
  278. See \f2XtDestroyApplicationContext\fP.
  279. .
  280. .Pr initialize-display context display application-name application-class
  281. See \f2XtDisplayInitialize\fP, \f2XtOpenDisplay\fP.
  282. If \f2display\fP is an object of type \f2display\fP,
  283. \f2XtDisplayInitialize\fP is called.
  284. If \f2display\fP is a display name (a string or a symbol) or #f,
  285. \f2XtOpenDisplay\fP is called (with a NULL display in the latter case),
  286. and the newly opened display is returned.
  287. \f2application-name\fP and \f2application-class\fP are strings or symbols
  288. or #f (NULL is used in the latter case).
  289. .
  290. .Pr application-initialize name . fallback-resources
  291. A convenience function that creates an application context by a call
  292. to \f2create-context\fP, sets the fallback resources (if any), initializes
  293. the display by a call to \f2initialize-display\fP with the specified
  294. \f2name\fP and a class of #f, and creates and returns an application
  295. shell with the name \f2name\fP and class #f.
  296. .LP
  297. Calling \f2application-initialize\fP more than once may cause the
  298. application contexts and displays that were created by earlier
  299. calls to be closed during a future garbage collection.
  300. .
  301. .Pr display\(mi>context display
  302. See \f2XtDisplayToApplicationContext\fP.
  303. .
  304. .Pr set-context-fallback-resources! context . resources
  305. See \f2XtAppSetFallbackResources\fP.
  306. Each \f2resource\fP is a string.
  307. .
  308. .Pr context-main-loop context
  309. See \f2XtAppMainLoop\fP.
  310. .
  311. .Pr context-pending context
  312. See \f2XtAppPending\fP.
  313. Returns a list of symbols (\f5x-event\fP, \f5timer\fP, \f5alternate-input\fP).
  314. .
  315. .Pr context-process-event context . mask
  316. See \f2XtProcessEvent\fP.
  317. The optional argument \f2mask\fP is a list of symbols (see
  318. \f2context-pending\fP above).
  319. \f2XtIMAll\fP is used if the \f2mask\fP argument is omitted
  320. .
  321. .Pr context-add-work-proc context procedure
  322. See \f2XtAppAddWorkProc\fP.
  323. Returns an \f2identifier\fP that can be used as an argument to
  324. \f2remove-work-proc\fP.
  325. \f2procedure\fP is a procedure with no arguments.
  326. .
  327. .Pr remove-work-proc identifier
  328. See \f2XtRemoveWorkProc\fP.
  329. \f2identifier\fP must be the return value of a previous call to
  330. \f2context-add-work-proc\fP.
  331. Each such \f2identifier\fP can be used as an argument for
  332. \f2remove-work-proc\fP only once.
  333. .
  334. .Pr context-add-timeout context timer-value procedure
  335. See \f2XtAppAddTimeOut\fP.
  336. \f2timer-value\fP is an integer.
  337. Returns an \f2identifier\fP that can be used as an argument to
  338. \f2remove-timeout\fP.
  339. The time-out procedure will be called with one argument, the identifier
  340. returned by the call to \f2context-add-timeout\fP (i.\|e. the object
  341. that uniquely identifies the timer).
  342. .
  343. .Pr remove-timeout identifier
  344. See \f2XtRemoveTimeOut\fP.
  345. \f2identifier\fP must be the return value of a previous call to
  346. \f2context-add-timeout\fP.
  347. Each such \f2identifier\fP can be used as an argument for
  348. \f2remove-timeout\fP only once.
  349. .
  350. .Pr context-add-input context source procedure . mask
  351. See \f2XtAppAddInput\fP.
  352. \f2source\fP is a file port.
  353. Returns an \f2identifier\fP that can be used as an argument to
  354. \f2context-remove-input\fP.
  355. The \f2procedure\fP will be called with two arguments \- \f2source\fP
  356. and the identifier returned by the call to \f2context-add-input\fP.
  357. .LP
  358. The optional \f2mask\fP argument is a list of one or more of the
  359. symbols \f2read\fP, \f2write\fP, and \f2exception\fP.
  360. It specifies the condition on which the procedure will be called.
  361. If no \f2mask\fP argument is given, \f2read\fP is used if \f2source\fP
  362. is an input-port, \f2write\fP if it is an output-port, and
  363. both \f2read\fP and \f2write\fP if it is an input-output-port.
  364. .
  365. .Pr remove-input identifier
  366. See \f2XtRemoveInput\fP.
  367. \f2identifier\fP must be the return value of a previous call to
  368. \f2context-add-input\fP.
  369. Each such \f2identifier\fP can be used as an argument for
  370. \f2remove-input\fP only once.
  371. .
  372. .Pr identifier? x
  373. Returns #t iff \f2x\fP is an \f2identifier\fP (an object returned by
  374. functions like \f2context-add-timeout\fP).
  375. .
  376. .Ch Translations Management Functions
  377. .
  378. .Pr context-add-action context name procedure
  379. See \f2XtAppAddActions\fP.
  380. \f2name\fP is the name of the action (a string or a symbol).
  381. The action procedure will be invoked with three arguments:
  382. a widget, a list of event-specific arguments (see \f2handle-events\fP)
  383. and a list of strings (the action arguments).
  384. .
  385. .Pr augment-translations widget translation-table
  386. See \f2XtAugmentTranslations\fP.
  387. \f2translation-table\fP is a string; \f2XtParseTranslationTable\fP is
  388. applied to it.
  389. .
  390. .Pr override-translations widget translation-table
  391. See \f2XtOverrideTranslations\fP.
  392. \f2translation-table\fP is a string; \f2XtParseTranslationTable\fP is
  393. applied to it.
  394. .
  395. .Pr uninstall-translations widget
  396. See \f2XtUninstallTranslations\fP.
  397. .
  398. .Pr install-accelerators dst-widget src-widget
  399. See \f2XtInstallAccelerators\fP.
  400. .
  401. .Pr install-all-accelerators dst-widget src-widget
  402. See \f2XtInstallAllAccelerators\fP.
  403. .
  404. .Pr multi-click-time display
  405. See \f2XtGetMultiClickTime\fP.
  406. Returns an integer.
  407. .
  408. .Pr set-multi-click-time! display time
  409. See \f2XtSetMultiClickTime\fP.
  410. \f2time\fP is an integer.
  411. .
  412. .Ch Error Handling
  413. .
  414. .Va xt-warning-handler
  415. See \f2XtSetWarningHandler\fP.
  416. When a warning message is to be printed by the Xt intrinsics and the
  417. global variable \f2xt-warning-handler\fP is bound to a compound
  418. procedure, this procedure is invoked with the error message (a string)
  419. as an argument.
  420. When this variable is not bound to a compound procedure, the message
  421. is sent to the current output port.
  422. The initial value of this variable is the empty list.
  423. .LP
  424. This interface is bogus and will be replaced by a more useful mechanism
  425. in future versions of the software.
  426. .
  427. .Ch Miscellaneous Functions
  428. .
  429. .Pr xt-release-4-or-later?
  430. Returns always #t.
  431. .
  432. .Pr xt-release-5-or-later?
  433. Returns #t iff the Xt extension is linked together with the X11
  434. Release 5 toolkit intrinsics or later versions of the intrinsics.
  435. .
  436. .Ch Interaction with the Garbage Collector
  437. .
  438. .PP
  439. .Ix "garbage collector"
  440. The Scheme garbage collector destroys objects of type \f2context\fP
  441. or \f2widget\fP that are not longer accessible from within the Scheme
  442. program.
  443. This is done by invoking the function \f2destroy-context\fP or
  444. \f2destroy-widget\fP, respectively, with the unreferenced object as
  445. an argument.
  446. .PP
  447. The garbage collector only destroys objects that have been created
  448. from with the Scheme program (by functions like \f2create-context\fP
  449. or \f2create-widget\fP).
  450. Objects that have been obtained from Xt through functions like
  451. \f2widget-context\fP (and are owned by the Xt internals),
  452. are ignored by the garbage collector.
  453. .PP
  454. Programmers must make sure that an object is accessible during the object's
  455. entire lifetime, otherwise future runs of the garbage collector can
  456. result in undesired termination of the object.
  457. One must be especially careful when results of functions that create
  458. new objects (such as \f2create-context\fP) are ignored or assigned
  459. to local variables as in
  460. .Ss
  461. (define (initialize)
  462.   (let* ((con (create-context))
  463.           (dpy (initialize-display con #f 'Test #f)))
  464.     (create-shell 'Test #f (find-class 'application-shell) dpy))))
  465. .Se
  466. .PP
  467. In this example, after termination of the function, the garbage
  468. collector will destroy the application context created by the
  469. call to \f2create-context\fP as well as the display,
  470. as they are no longer directly accessible from within the program.
  471. Bugs like this are often hard to find, since (in the above example)
  472. the shell widget returned by \f2initialize\fP can still be used,
  473. although its application context and the display associated with
  474. the application context have already been destroyed.
  475. .PP
  476. The problem can be solved by re-writing the above function like this:
  477. .Ss
  478. (define initialize #f)
  479. .sp .5
  480. (let ((con) (dpy))
  481.   (set! initialize
  482.     (lambda ()
  483.       (set! con (create-context))
  484.       (set! dpy (initialize-display con #f 'Test #f))
  485.       (create-shell 'Test #f (find-class 'application-shell) dpy))))
  486. .Se
  487. .PP
  488. An alternative solution is to place the application context and
  489. display into a global variable, so that they can be terminated
  490. explicitly by the program when desired.
  491. .PP
  492. One must also be careful when creating children of composite widgets.
  493. Since the garbage collector does not know about the Xt-internal
  494. relationship between parent and child widgets, the child widgets must
  495. be kept in variables that are visited by the garbage collector to
  496. ensure that they are not counted as ``garbage'' and destroyed
  497. prematurely.
  498.